//
//  SecondViewController.swift
//  zhichidata
//
//  Created by joke on 15/12/22.
//  Copyright © 2015年 joke. All rights reserved.
//

import UIKit
import Alamofire
import SwiftyJSON


class SecondViewController: UIViewController {

    @IBOutlet weak var test: UILabel!
    @IBOutlet weak var count1: UILabel!
    @IBOutlet weak var rest1: UILabel!
    @IBOutlet weak var count2: UILabel!
    @IBOutlet weak var rest2: UILabel!
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "two"
        //test.font = UIFont(name: "glyphicons-halflings-regular", size: 22)
        //test.text = "\\e162"
        
        
        
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        
        // Dispose of any resources that can be recreated.
    }

    override func viewWillAppear(animated: Bool) {
        dataReceiveTwo()
        dataReceiveOne()
    }
    
    func dataReceiveOne(){
        Alamofire.request(.GET, "http://red.paperpass.com:8080/resart/api/getproxycount.do?proxykey=B65CEE99D6DA02235AD32BB41C19D5EC").responseJSON() {
            (data) in
            print(1,data)
            switch data.result {
            case .Success(_):
                if let value = data.result.value{
                    let json = JSON(value)
                    print(2)
                    self.count1.text = json["count"].stringValue
                    self.rest1.text = json["rest"].stringValue
                }
            case .Failure(let error):
                print(error)
            }
            
        }

    }
    
    func dataReceiveTwo(){
        Alamofire.request(.GET, "http://red.paperpass.com:8080/resart/api/getsercount.do?proxykey=B65CEE99D6DA02235AD32BB41C19D5EC").responseJSON() {
            (data) in
            print(2,data)
            switch data.result {
            case .Success(_):
                if let value = data.result.value{
                    let json = JSON(value)
                    print(2)
                    self.count2.text = json["count"].stringValue
                    self.rest2.text = json["rest"].stringValue
                }
            case .Failure(let error):
                print(error)
            }
            
        }
        
    }

}

